package 
{
	import app.facade.App;
	import flash.desktop.NativeApplication;
	import flash.events.Event;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.filesystem.File;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.ui.Multitouch;
	import flash.ui.MultitouchInputMode;
	import so.cuo.platform.admob.Admob;
	import so.cuo.platform.admob.AdmobPosition;
	
	/**
	 * ...
	 * @author PHANCUONG87
	 */
	[SWF(backgroundColor = "#000000", frameRate = "24", width = "960", height = "640")]
	public class Main extends Sprite 
	{
		
		public static var ROOT:*;
		public function Main():void 
		{
			Main.ROOT = this;	
			Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
			loadSWF();
		}
		private function loadSWF(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			loadBytes();
		}
		private function loadBytes():void {
            stage.addEventListener(Event.ENTER_FRAME, loadApp);
			stage.addEventListener(Event.DEACTIVATE, deactivate);
		}
		private function loadApp(evt:Event = null):void {
			if (stage.loaderInfo.bytesLoaded == stage.loaderInfo.bytesTotal) {
				stage.removeEventListener(Event.ENTER_FRAME, loadApp);
				App.getInstance().startup(stage); 
			}
		}		
		
		private function deactivate(e:Event):void 
		{
			// make sure the app behaves well (or exits) when in background
			//NativeApplication.nativeApplication.exit();

		}

	}
	
}